<!-- 首页 -->
<template>
	<view class="container">
		<view class="flex flex-direction align-center" style="margin-top: 254rpx;">
			<image src="/static/images/login/time.png" style="width: 116rpx;height: 116rpx;" mode=""></image>
			<text class="f-s20 f-w500 m-t20">认证信息提交成功</text>
			<text class="m-t10 text-gray">预计3个工作日内完成审核，请随时关注本页面!</text>
			<view class="self-btn flex m-t30" style="width: 320rpx;" hover-class="pressed" @click="handleToPage">
				<image src="/static/images/login/time-white.png" class="width-20 height-20" mode="widthFix"></image>
				<text style="margin-left: 8rpx;">正在审核中</text>
			</view>
		</view>
		<Toast></Toast>
	</view>
</template>

<script>
	import {
		authDetails
	} from '@/api/mine/auth.js'
	export default {
		name:"",
		data() {
			return {
				
			}
		},
		methods: {
			handleToPage(){
				this.$modal.loading('正在查询审核状态').then(()=>{
					this.checkAuth()
				})
			},
			// 检查认证情况
			checkAuth(){
				// 认证情况
				authDetails().then(res => {
					let {
						data: {
							tcp = {}, // 嵌套默认值
							identity = {},
							data: data_auth = {},
							life_photos = {},
							vivid_photos = {},
							video = {},
						} = {}
					} = res || {} // 最外层也设置默认值
					let tcpStatus = tcp?.status
					let identityStatus = identity?.status ?? 2
					let dataStatus = data_auth?.status ?? 2
					let lifeStatus = life_photos?.status ?? 2
					let imageStatus = vivid_photos?.status ?? 2
					let videoStatus = video?.status ?? 2
					// 检查签署协议情况
					if (tcpStatus === 1) {
						this.$modal.closeLoading()
						// 已签署
						const statusList = [identityStatus, dataStatus, lifeStatus, imageStatus, videoStatus]
						let indexResule = statusList.indexOf(2)
						// 判断是否至少有一个环节为审核被驳回
						if (indexResule !== -1) {
							switch (indexResule) {
								case 0:
									// 实名认证被驳回
									this.$tab.redirectTo('./steps/index?stepsNumber=1')
									break;
								case 1:
									// 基本资料
									this.$tab.redirectTo('./steps/index?stepsNumber=2&current=1')
									break;
								case 2:
									// 形象照片
									this.$tab.redirectTo('./steps/index?stepsNumber=2&current=2')
									break;
								case 3:
									// 生活圈
									this.$tab.redirectTo('./steps/index?stepsNumber=2&current=3')
									break;
								case 4:
									// 生活视频
									this.$tab.redirectTo('./steps/index?stepsNumber=2&current=4')
									break;
								default:
									this.$tab.redirectTo('./steps/index?stepsNumber=3')
									break;
							}
						} else if (statusList.some(element => element === 0)) {
							// 判断是否至少有一个环节为审核中状态
							this.$modal.closeLoading()
				
						} else {
							// 进入首页
							this.$modal.closeLoading()
							this.$tab.reLaunch('/pages/index/index')
						}
				
					} else {
						// 未签署，跳转签署服务协议页
						this.$modal.closeLoading()
						this.$tab.redirectTo('merchant-agreement')
					}
				}).catch(() => this.$modal.closeLoading())
			}
		}
	}
</script>

<style scoped lang="scss">
	.container{
		
	}
</style>
